// 03myCenter/02sectorization/01myChange/financialDetails/financialDetails.js
var co = require('../../../../resource/js/common.js')
var details = [], pageNum = 1
var app = getApp()
var _this

Page({
   /*页面的初始数据*/
   data: {
      details: [],
      userMoney: [],
      hint: false
   },
   /* 生命周期函数--监听页面加载*/
   onLoad: function (options) {
      _this = this
      if (details.length == 0) {
         this.getDetails(1)
      } else {
         this.setData({ details: details })
      }
      // console.log("【获取用户余额】===", app.aData.userInfos.User_Money)
   },
   // 获取财务明细
   getDetails() {
      var param = {
         // app.Data.userInfo.User_ID
         User_ID: 53,
         pageNo: pageNum
      }
      co.getShareApi('distribute/Account/getRecord', param, function (res) {
         if (res.code == 0) {
            wx.showToast({ //期间为了显示效果可以添加一个过度的弹出框提示“加载中” 
               title: '数据加载中',
               icon: 'loading',
               duration: 200
            })
            pageNum++
            var list = _this.data.details
            _this.setData({ details: list.concat(res.data) })
         } else {
            _this.setData({ hint: true })
         }
         // console.log('【请求页码】===', pageNum)
         // console.log('【返回数据】===', _this.data.details.length)
         // 用户余额
         // var user_money = parseFloat(app.aData.userInfos.User_Money)
         // var money = 0.00
         // for(var i=0;i<res.data.length;i++){
         //    var num = parseFloat(res.data[i].Record_Money)
         //    money = money + num
         // }
         // var userMoney = money + user_money
         // _this.setData({ userMoney: userMoney }) 
         // console.log("【赚取的金额】===", money)    
      })
   },
   // 加载更多
   setLoading: function (e) {
      _this.getDetails()
   },
   onReachBottom: function () {
      this.getDetails()
   },
   /*生命周期函数--监听页面卸载 */
   onUnload: function () {
      details = this.data.details
   },
})